<template>
  <div class="login-container">
    <el-form
      ref="loginFormRef"
      :model="loginForm"
      :rules="loginRules"
      class="login-form"
      label-position="left"
    >
      <div class="title-container">
<<<<<<< HEAD
        <h3 class="title">研途</h3>
=======
        <h3 class="title">研途后台</h3>
>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
      </div>

      <el-form-item prop="username">
        <span class="svg-container">
          <el-icon><User /></el-icon>
        </span>
        <el-input
          ref="usernameRef"
          v-model="loginForm.username"
          placeholder="用户名"
          name="username"
          type="text"
          tabindex="1"
        />
      </el-form-item>

      <el-form-item prop="password">
        <span class="svg-container">
          <el-icon><Lock /></el-icon>
        </span>

        <el-input
          ref="passwordRef"
          v-model="loginForm.password"
          placeholder="密码"
          name="password"
          tabindex="2"
          show-password
        />
      </el-form-item>

      <el-button
        type="primary"
        style="width: 100%; margin-bottom: 30px"
        @click="handleLogin"
        >登录</el-button
      >
<<<<<<< HEAD
      <el-button type="primary">注册</el-button>
      <el-button type="success" style="float: right" @click="weixin"
        >微信登录</el-button
      >
    </el-form>
  </div>
  <Dialog v-model="dialogVisible" @inituserlist="inigetuser" />
=======
    </el-form>
  </div>
>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useStore } from 'vuex'
<<<<<<< HEAD
import Dialog from './components/dialog.vue'
import Edit from './components/edit.vue'
import { encryptByDES } from '@/utils/des'
import cryptoJs from 'crypto-js'
const store = useStore()
=======

const store = useStore()

>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
const loginForm = ref({
  username: '',
  password: ''
})
const validateUsername = (rule, value, callback) => {
  if (value.length < 4) {
    callback(new Error('请输入合法用户名'))
  } else {
    callback()
  }
}
const validatePassword = (rule, value, callback) => {
  if (value.length < 5) {
    callback(new Error('请输入正确密码'))
  } else {
    callback()
  }
}
const loginRules = ref({
  username: [{ required: true, trigger: 'blur', validator: validateUsername }],
  password: [{ required: true, trigger: 'blur', validator: validatePassword }]
})
<<<<<<< HEAD
=======

>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
const loginFormRef = ref(null)
const handleLogin = () => {
  loginFormRef.value.validate(async (valid) => {
    if (valid) {
<<<<<<< HEAD
      //  加密暂时注释掉
      // console.log(encryptByDES(loginForm.value.password))
      // loginForm.value.password = encryptByDES(loginForm.value.password)
      store.dispatch('app/login', loginForm.value)
=======
      // console.log(loginForm.value)
      store.dispatch('app/login', loginForm.value)
      // await login(loginForm.value).then(function (result) {})
>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
    } else {
      console.log('error submit!!')
      return false
    }
  })
}
<<<<<<< HEAD
const dialogVisible = ref(false)
const weixin = () => {
  dialogVisible.value = true
}
</script>
=======

onMounted(() => {
  // ...
})
</script>

>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
<style lang="scss">
$bg: #283443;
$light_gray: #fff;
$cursor: #fff;
<<<<<<< HEAD
=======

@supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  .login-container .el-input input {
    color: $cursor;
  }
}

/* reset element-ui css */
>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
.login-container {
  .el-input {
    display: inline-block;
    height: 47px;
    width: 85%;
<<<<<<< HEAD
=======

>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
    input {
      background: transparent;
      border: 0px;
      -webkit-appearance: none;
      border-radius: 0px;
      padding: 12px 5px 12px 15px;
      color: $light_gray;
      height: 47px;
      caret-color: $cursor;
    }
  }
<<<<<<< HEAD
=======

>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
  .el-form-item {
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.1);
    border-radius: 5px;
    color: #454545;
  }
}
</style>

<style lang="scss" scoped>
$bg: #2d3a4b;
$dark_gray: #889aa4;
$light_gray: #eee;

.login-container {
  min-height: 100%;
  width: 100%;
  background-color: $bg;
  overflow: hidden;

  .login-form {
    position: relative;
    width: 520px;
    max-width: 100%;
    padding: 30px 50px 10px 50px;
    margin: 120px auto auto auto;
    overflow: hidden;
    background: rgba(252, 254, 255, 0.11);
  }

<<<<<<< HEAD
=======
  .tips {
    font-size: 14px;
    color: #fff;
    margin-bottom: 10px;

    span {
      &:first-of-type {
        margin-right: 16px;
      }
    }
  }

>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
  .svg-container {
    padding: 6px 5px 6px 15px;
    color: $dark_gray;
    vertical-align: middle;
    width: 30px;
    display: inline-block;
  }

  .title-container {
    position: relative;

    .title {
      font-size: 26px;
      color: $light_gray;
      margin: 0px auto 40px auto;
      text-align: center;
      font-weight: bold;
    }
  }

  .show-pwd {
    position: absolute;
    right: 10px;
    top: 7px;
    font-size: 16px;
    color: $dark_gray;
    cursor: pointer;
    user-select: none;
  }
<<<<<<< HEAD
=======

  .thirdparty-button {
    position: absolute;
    right: 0;
    bottom: 6px;
  }

  @media only screen and (max-width: 470px) {
    .thirdparty-button {
      display: none;
    }
  }
>>>>>>> 7d520118954f103433f5074ad63a16f5b63acf51
}
</style>
